class SonglistController < ApplicationController
  
  def index
    @songs = Song.all(:include => :artist);
    #    @songs = Song.find_by_sql("select s.* from songs s left join artists a on s.artist_id = a.id
    #                              order by a.name, s.title")
    @songs.sort! do |a,b|
      res1 = a.artist.name <=> b.artist.name
      if res1 == 0
        a.title <=> b.title
      else
        res1
      end
    end
  end

end